package com.xb.system.controller;

import com.xb.model.domain.entity.CustomerService;
import com.xb.system.common.result.Result;
import com.xb.system.service.CustomerServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/support")
public class CustomerServiceController {

    @Autowired
    private CustomerServiceService customerServiceService;

    @GetMapping("/getCustomerService")
    public Result<Map<String, Object>> getCustomerService() {
        CustomerService customerService = customerServiceService.getCustomerServiceInfo();
        Map<String, Object> data = new HashMap<>();
        if (customerService != null) {
            data.put("wechatId", customerService.getWechatId());
            data.put("qrcodeUrl", customerService.getQrcodeUrl());
            data.put("description", customerService.getDescription());
            return Result.ok(data);
        }
        return Result.fail();
    }

    @PostMapping("/updateCustomerService")
    public Result<String> updateCustomerService(@RequestBody CustomerService customerService) {
        boolean success = customerServiceService.updateCustomerService(customerService);
        if (success) {
            return Result.ok("更新成功");
        }
        return Result.fail("更新失败");
    }
}